import React, { PureComponent } from 'react'

export default class Parent extends PureComponent {
    state = {
        carName: '迈巴赫'
    }
    change = () => {
        this.setState({ carName: '法拉利' })
    }
    render() {
        let { carName } = this.state
        console.log('father----');
        return (
            <div>
                <h1>父组件</h1>
                <h1>{carName}</h1>
                <button onClick={this.change}>点击修改</button>
                <Child />
            </div>
        )
    }
}

class Child extends PureComponent {
    render() {
        console.log('son----');
        return (
            <div>
                <h2>子组件</h2>
            </div>
        )
    }
}
